{extend name="$admin_layout" /}
{block name="content"}
<script src="__PLUG__/layer/laydate/laydate.js?v={:config('asset_version')}"></script>
<script src="/static/plugins/jquery/jquery.min.js"></script>
<style>
     .form-control[readonly]{
         background-color: #ffffff;
     }
</style>
<div class="row">
    <div class="col-md-12">
        <div class="box nav-tabs-custom" style="border-top: 0;">	    
			<ul class="nav nav-tabs">
				<li {if condition="!isset($active)"}class="active"{/if} > <a href="{:url('order/order/invoice_list')}">{:lang('全部')}</a> </li>
				{volist name="tab_list" id="tab"}
    				<li {if strval($field) === strval($tab['field'])}{if strval($active) === strval($tab['value']) }class="active"{/if}{/if}> 
    				    <a href="{$tab.url}">{$tab.title}</a> 
    				</li>
				{/volist}
		    </ul>
			<div class="box-body">
				<div class="tab-pane active">
					<div class="row">
						<form action="" method="get" class="marBtm">
							<div class="col-md-2 col-xs-6">
								<span class="txt">{:lang('订单号')}：</span>
								<input type="text" class="form-control" name="order_sn" placeholder="{:lang('请输入订单号')}" value="{:input('param.order_sn')}">
							</div>
<!--                            <div class="col-md-2 col-xs-6">-->
<!--                                <span class="txt">{:lang('发货单号')}：</span>-->
<!--                                <input type="text" class="form-control" name="invoice_send_goods_num" placeholder="{:lang('请输入发货单号')}" value="{:input('param.invoice_send_goods_num')}">-->
<!--                            </div>-->
                            <div class="col-md-2 col-xs-6">
                                <span class="txt">{:lang('发票抬头')}：</span>
                                <input type="text" class="form-control" name="invoice_title" placeholder="{:lang('请输入发票抬头')}" value="{:input('param.invoice_title')}">
                            </div>
							<div class="col-md-3 col-xs-6">
								<span class="txt">{:lang('申请开票时间')} ：</span>
								<input type="date" class="form-control js-date" readonly name="invoice_add_time" placeholder="{:lang('请选择申请开票时间')}" value="{$Think.get.invoice_add_time}">
							</div>
							<div class="col-md-2 col-xs-6" style="padding-top: 18px;">
								<button class="btn btn-primary btn-flat" type="submit">{:lang('搜索')}</button> <button class="btn btn-default btn-flat" type="button" onclick="clearinput()">{:lang('重置')}</button>
							</div>
						</form>
					</div>
				</div>
			</div>
            <div class="box-body">
                <div class="tab-pane active">
                    <div  style="overflow: auto;">
                    <table  class="table table-builder table-hover table-bordered table-striped mb10">
                        <thead>
                            <th class="">{:lang('订单编号')}</th>
<!--                            <th class="text-center">{:lang('发票发货单号')}</th>-->
                            <th class="text-center">{:lang('发票申请类型')}</th>
                            <th class="text-center">{:lang('发票状态')}</th>
                            <th class="text-center">{:lang('开票金额')}</th>
                            <th class="text-center">{:lang('开票抬头')}</th>
                            <th class="text-center">{:lang('纳税人识别号')}</th>
                            <th class="text-center">{:lang('企业开户行')}</th>
                            <th class="text-center">{:lang('开票公司银行账号')}</th>
                            <th class="text-center">{:lang('开票公司注册地址')}</th>
                            <th class="text-center">{:lang('开票公司电话')}</th>
                            <th class="text-center">{:lang('申请开票时间')}</th>
                            <th class="text-center">{:lang('操作')}</th>
                        </thead>
                        <tbody>
                        {volist name="list" id="o"}
                            <tr>
                                <td class=""><a id="order_sn{$key}" ident="edit" title="{:lang('详情')}" href="{:url('detail',['order_sn'=>$o['order_sn']])}" class="mr5">{$o.order_sn}</a></td>
<!--                                <td class="">{$o.invoice_send_goods_num}</td>-->
                                <input type="hidden" id="aid{$key}" value="{$o.aid}">
                                <td class="text-center">{$o.invoice_type_name}</td>
                                <td class="text-center">{$o.invoice_status_name}</td>
                                <td class="text-center">{$o.real_money}</td>
                                <td class="text-center">{$o.invoice_title}</td>
                                <td class="text-center">{$o.invoice_company_duty_paragraph}</td>
                                <td class="text-center">{$o.invoice_company_bank}</td>
                                <td class="text-center">{$o.invoice_company_bank_num}</td>
                                <td class="text-center">{$o.invoice_company_address}</td>
                                <td class="text-center">{$o.invoice_company_phone}</td>
                                <td class="text-center">{$o.invoice_add_time}</td>
                                <td class="text-center">
                                    {if condition="$o.invoice_status == 1"}
                                    未开票
<!--								        <a title="{:lang('开票')}"  href="javascript:void(0);" onclick="getGoodsSkuData({$key})" class="mr5 btn btn-xsbtn-default"><i class=" fa fa-print pr5"></i>{:lang('开票')}</a>-->
                                    {/if}
                                    {if condition="$o.invoice_status == 2"}
                                    已开票
                                    {/if}
                                    <a ident="edit" title="编辑" href="/admin.php/order/order/invoice_edit/id/{$o.id}/layer/1.html" class="btn btn-xs mr5 btn-default layeredit"><i class="fa fa-upload pr5"></i>上传电子发票</a>
                                </td>
                            </tr>
                        {/volist}
                        </tbody>
                    </table>
                    <div class="data-table-toolbar">
                        <div class="row">
                            {$pages|raw}
                        </div>
                    </div>
                </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    // 开票
    function getGoodsSkuData(key)
    {
        // 获取参数
        var order_sn = $('#order_sn' + key).html();
        var id = $('#aid' + key).val();

        layer.open({
            type: 2,
            skin: '', //加上边框
            area: ['600px', '400px'], //宽高
            content: '/admin.php/order/order/invoice?id=' + id + '&order_sn=' + order_sn
        });
    }
    function clearinput(){
        $(".marBtm").find('input').val('');
        $(".marBtm").find(".select2").val('all').trigger('change');
    }

    $('.layeredit').click(function (e) {
		e.preventDefault()
		quickadd_href = $(this).attr('href');
		quickadd_href = quickadd_href + '?layer=1';
		opensidebar(quickadd_href)
	});

    function opensidebar(url) {
		console.log(url);
		layer.open({
			type: 2,
			title: false,
			closeBtn: false,
			shadeClose: true,
			scrollbar: true,
			offset: 'r',
			anim: '7',
			area: ['50%', '100vh'],
			content: url
		})
	}

</script>

{/block}
